package org.cainiao.api.lark.impl.imperative.authenticateandauthorize.getaccesstokens;

import lombok.RequiredArgsConstructor;
import org.cainiao.api.lark.dto.response.LarkDataResponse;
import org.cainiao.api.lark.dto.response.authenticateandauthorize.getaccesstokens.AppAccessTokenResponse;
import org.cainiao.api.lark.dto.response.authenticateandauthorize.getaccesstokens.LarkTokenInfo;
import org.cainiao.api.lark.imperative.authenticateandauthorize.getaccesstokens.restoperations.GetAccessTokens;
import org.cainiao.api.lark.imperative.authenticateandauthorize.getaccesstokens.restoperations.GetAccessTokensWithAppAccessToken;
import org.cainiao.api.lark.imperative.authenticateandauthorize.getaccesstokens.restoperations.GetAccessTokensWithOutAccessToken;
import org.springframework.http.ResponseEntity;

/**
 * <br />
 * <p>
 * Author: Cai Niao(wdhlzd@163.com)<br />
 */
@RequiredArgsConstructor
public class WebClientGetAccessTokens implements GetAccessTokens {

    private final GetAccessTokensWithOutAccessToken getAccessTokensWithOutAccessToken;
    private final GetAccessTokensWithAppAccessToken getAccessTokensWithAppAccessToken;

    @Override
    public ResponseEntity<AppAccessTokenResponse> getCustomAppAppAccessToken(String appId, String appSecret) {
        return getAccessTokensWithOutAccessToken.getCustomAppAppAccessToken(appId, appSecret);
    }

    @Override
    public ResponseEntity<LarkDataResponse<LarkTokenInfo>> refreshUserAccessToken(String refreshToken) {
        return getAccessTokensWithAppAccessToken.refreshUserAccessToken(refreshToken);
    }
}
